<?php if($this->pagecount>1):?>
<?php $max=$this->page+5;if($max>$this->pagecount)$max=$this->pagecount;?>


<div class="paginator">
<?php if ($this->page>1):?>
		<?php $prev=$this->page-1?>
		<a class="prev" href="<?php echo $this->link.$prev?>">&lt;</a>
		<?php if($this->page>6):?>
		&nbsp;<a href="<?php echo $this->link."1"?>">(1)</a>&nbsp;...
		<?php endif;?>
		
<?php endif;?>
<?php if($this->page>5):?>

    <?php for ($i=$this->page-5;$i<=$max;$i++):?>
		<?php if($i!=$this->page):?>
			<a href="<?php echo $this->link.$i?>"><?php echo $i?></a>
		<?php else:?>
			<span><?php echo $i?></span>
		<?php endif;?>
	<?php endfor;?>
<?php endif;?>	

<?php if($this->page<=5):?>
    	
    <?php for ($i=1;$i<=$max;$i++):?>
		<?php if($i!=$this->page):?>
			<a href="<?php echo $this->link.$i?>"><?php echo $i?></a>
		<?php else:?>
			<span><?php echo $i?></span>
		<?php endif;?>
	<?php endfor;?>
<?php endif;?>	


<?php if ($this->page!=$this->pagecount):?>
		<?php $next=$this->page+1?>
		<?php if($this->pagecount-$this->page>5):?>
		...<a href="<?php echo $this->link.$this->pagecount?>">(<?=$this->pagecount ?>)</a>&nbsp;
		<?php endif;?>
		<a class="next" href="<?php echo $this->link.$next?>">&gt;</a>
<?php endif;?>
</div>

<?php endif;?>